<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <meta name="description" content="">
    <meta name="author" content="">

    <title>后台</title>

    <link href="__PUBLIC__/images/favicon.ico" rel="shortcut icon" />

    <!-- Bootstrap core CSS -->
    <link rel="stylesheet" href="__PUBLIC__/css/bootstrap.min.css" />
    <link rel="stylesheet" href="__PUBLIC__/css/bootstrap-theme.min.css" />
    <link rel="stylesheet" href="__PUBLIC__/css/dashboard.css" />
    <link rel="stylesheet" href="__PUBLIC__/css/icheck/all.css" />
    <link rel="stylesheet" href="__PUBLIC__/css/bootstrap-datetimepicker.css" />
</head>

<body>

<include file="Common/topNav" />

<div class="container-fluid">
    <div class="row">
        <include file="Common/leftMenu" />
        <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
            <div class="cont-title clearfix">
                <div class="title">租赁需求</div>
            </div>
            <form class="jc-search form-inline searchForm" action="{:U('Admin/Rental/leaseRequirementList')}" method="post">
                <div class="form-group">
                    <label>街道:</label>
                    <select class="form-control" name="org_id">
                        <volist name="orgs" id="item">
                            <option <if condition="orgId eq $item['id']">selected="selected"</if> value="{$item.id}">{$item.name}</option>
                        </volist>
                    </select>
                </div>
                <div class="form-group">
                    <label>状态:</label>
                    <select class="form-control" name="audit">
                        <option value="-1">全部</option>
                        <option value="0" <if condition="$audit eq 0">selected</if>>待审核</option>
                        <option value="1" <if condition="$audit eq 1">selected</if>>已审核</option>
                        <option value="2" <if condition="$audit eq 2">selected</if>>未通过</option>
                    </select>
                </div>
                <div class="form-group">
                    <label>发布时间:</label>
                    <div class='input-group date col-sm-7' id='datetimepicker'>
                        <input type='text' value="{$_REQUEST['create_time']}" name="create_time" class="form-control " data-date-format="yyyy-mm-dd" />
                        <span class="input-group-addon">
                            <span class="glyphicon glyphicon-calendar"></span></span>
                    </div>
                </div>
                <input class="btn" type="submit" value="查询" />
            </form>
            <div class="table-responsive">
                <table class="table table-striped table-hover" id="tableData">
                    <thead>
                    <tr>
                        <th>街道</th>
                        <th>需求面积（m²）</th>
                        <th>意向租金（元/月）</th>
                        <th>租赁人</th>
                        <th>租赁人电话</th>
                        <th>状态</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <empty name="leaseRequiredList['list']">
                        <tr>
                            <td colspan="10">没有相关记录</td>
                        </tr>
                    </empty>
                    <foreach name="leaseRequiredList['list']" item="leaseRequire">
                        <tr>
                            <td>{$leaseRequire.org.name}</td>
                            <td>{$leaseRequire.area|number_format=2}</td>
                            <td>{$leaseRequire.rent|number_format=2}</td>
                            <td>{$leaseRequire.user.user_name}</td>
                            <td>{$leaseRequire.user.mobile}</td>
                            <td>
                                <if condition="$leaseRequire.audit eq 0">
                                    <span class="label label-warning">待审核</span>
                                <elseif condition="$leaseRequire.audit eq 1" />
                                    <span class="label label-success">已审核</span>
                                <else/>
                                    <span class="label label-danger">未通过</span>
                                </if>
                            </td>
                            <td>
                                <if condition="$leaseRequire.audit eq 0">
                                    <a thisId="{$leaseRequire.id}" href="javascript:void(0);" class="audit" >审核</a>
                                <else/>
                                    -
                                </if>
                            </td>
                        </tr>
                    </foreach>
                    </tbody>
                </table>
                <div class="page">
                	{$leaseRequiredList.page}
                </div>
            </div>
        </div>
    </div>
</div>

<include file="Common/modalHtmls" />
<script type="text/javascript" src="__PUBLIC__/js/jquery.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/bootstrap.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/common.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/icheck.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/bootstrap-datetimepicker.js"></script>
<script type="text/javascript">
    $(function(){

    });


    function addLease(){
        common.htmlAjax("{:U('Admin/Lease/add')}", {}, function (html) {
            $("#commonModal").html(html).modal('toggle');
        });
    }

    function delLeaseBatch(){
        var str = "";
        $("input[name='lease_check[]']:checkbox").each(function(){
            if(true == $(this).is(':checked')){
                str += "," + $(this).val();
            }
        });
        if(str == ""){
            common.alert("提示","请至少选择一条记录");
            return;
        }
        common.confirm("提示","确认删除选中的楼宇吗？",function(){
            str = str.substring(1);
            var param = {id:str};
            $.ajax({
                url: "{:U('Admin/Lease/delete')}",
                type: "post",
                dataType: "json",
                data: param,
                success: function (data) {
                    if(data.status){
                        common.alert("提示","楼宇已成功删除!",function(){
                            common.reload();
                        });
                    }
                }
            });
        });
    }

  /*  $('.audit').click(function(){
        alert();
       /!* var id = $(this).attr("thisId");
        common.htmlAjax("{:U('Admin/Rental/confirm')}", {id:id}, function (html) {
            $("#commonModal").html(html).modal('toggle');
        });*!/
    }*/

    $(".audit").click(function () {
        var id = $(this).attr("thisId");
        common.htmlAjax("{:U('Admin/Rental/requireConfirm')}", {id: id}, function (html) {
            $("#commonModal").html(html).modal('toggle');
        })
    })

    $('#datetimepicker').datetimepicker({
        format: 'yyyy-mm-dd',
        language: 'ch',
        pickDate: true,
        pickTime: false,
        autoclose:true,
        minView:2,
        //pickerPosition:"bottom-left"
    });
</script>
</body>
</html>
